<script type="text/javascript" src="{$base_dir}modules/general_emr/js/AJAX_Eye_Refraction.js"></script>
{literal}
<script type="text/javascript">
	jQuery(document).ready(function() {
		$('#rightVisualAcuity').blur(function() {
			$('#leftVisualAcuity').val($(this).val());
		});	
			
		$('#rightCVA').blur(function() {
			checkCVA($(this));
		});		
		$('#leftCVA').blur(function() {
			checkCVA($(this));
		});	
		$('#rightUCVA').blur(function() {
			checkCVA($(this));
		});	
		$('#leftUCVA').blur(function() {
			checkCVA($(this));
		});	
		$('#bothEyesight').blur(function() {
			checkCVA($(this));
		});
		$('#rightRefractionType').blur(function() {
			checkType($(this));
		});
		$('#leftRefractionType').blur(function() {
			checkType($(this));
		});
		$('#rightCurrentDiopter').blur(function() {
			checkCurrentDiopter($(this));
		});
		$('#leftCurrentDiopter').blur(function() {
			checkCurrentDiopter($(this));
		});
		$('#rightSuggestion').blur(function() {
			checkSuggestion($(this));
		});
		$('#leftSuggestion').blur(function() {
			checkSuggestion($(this));
		});
		$('#rightCorrectGlass').blur(function() {
			checkCorrectGlass($(this));
		});
		$('#leftCorrectGlass').blur(function() {
			checkCorrectGlass($(this));
		});
		
		$('#refNote').keypress(function(event) {
			checkNote($(this));
		});
	});
	
	function checkNote(obj) {
		var text = $.trim(obj.val());
		text = text.toLowerCase();	
		if (text.match(/^t$/)) {
			obj.val({/literal}'{translate}Practise wearing glasses{/translate}\n{translate}Regular wearing glasses{/translate}\n{translate}Re-examination every 6 month{/translate}'{literal});
			return;					
		}
		
		if (text.match(/^d$/)) {
			obj.val({/literal}'{translate}Regular wearing glasses{/translate} \n{translate}Re-examination every 6 month{/translate}'{literal});
			return;					
		}
	}
	
	function checkCVA(obj) {			
		var text = $.trim(obj.val());
		text = text.toLowerCase();	
		if (text.match(/^[0-9]+[+|-]?$/)) {
			obj.val(text + '/10');
			return;					
		}
		if (text.match(/^d$/)) {
			obj.val({/literal}'{translate}Count fingers{/translate}'{literal});
			return;
		}
		if (text.match(/^[s]+[+]?$/)) {
			obj.val({/literal}'{translate}Light and shade positive{/translate} (+)'{literal});
			return;
		}
		if (text.match(/^s-$/)) {
			obj.val({/literal}'{translate}Sáng tối âm tính{/translate} (-)'{literal});
			return;
		}
		if (text.match(/^b$/)) {
			obj.val({/literal}'{translate}Shadow of hand{/translate}'{literal});
			return;
		}
		if (text.match(/^c$/)) {
			obj.val({/literal}'{translate}Patient not co-operate yet{/translate}'{literal});
			return;
		}
	}
	
	function checkType(obj) {			
		var text = $.trim(obj.val());
		text = text.toLowerCase();
		if (text.match(/^c$/)) {
			obj.val({/literal}'{translate}Myopic{/translate}'{literal});
			return;
		}
		if (text.match(/^lc$/)) {
			obj.val({/literal}'{translate}Loạn cận đơn{/translate}'{literal});
			return;
		}
		if (text.match(/^ck$/)) {
			obj.val({/literal}'{translate}Loạn cận kép{/translate}'{literal});
			return;
		}
		if (text.match(/^v$/)) {
			obj.val({/literal}'{translate}Hypermetrope{/translate}'{literal});
			return;
		}		
		if (text.match(/^lv$/)) {
			obj.val({/literal}'{translate}Loạn viễn đơn{/translate}'{literal});
			return;
		}
		if (text.match(/^vk$/)) {
			obj.val({/literal}'{translate}Loạn viễn kép{/translate}'{literal});
			return;
		}		
		if (text.match(/^l$/)) {
			obj.val({/literal}'{translate}Astigmatism{/translate}'{literal});
			return;
		}		
		if (text.match(/^lh$/)) {
			obj.val({/literal}'{translate}Loạn hỗn hợp{/translate}'{literal});
			return;
		}		
		if (text.match(/^b$/)) {
			obj.val({/literal}'{translate}Normal{/translate}'{literal});
			return;
		}		
	}
	function checkCurrentDiopter(obj) {			
		var text = $.trim(obj.val());
		text = text.toLowerCase();
		if (text.match(/^c$/)) {
			obj.val({/literal}'{translate}Not use yet{/translate}'{literal});
			return;
		}
		if (text.match(/^d$/)) {
			obj.val({/literal}'{translate}Used{/translate}'{literal});
			return;
		}
		if (text.match(/^da$/)) {
			obj.val({/literal}'{translate}In Use{/translate}'{literal});
			return;
		}
	}
	function checkSuggestion(obj) {			
		var text = $.trim(obj.val());
		text = text.toLowerCase();
		if (text.match(/^k$/)) {
			obj.val({/literal}'{translate}Without correction{/translate}'{literal});
			return;
		}
		if (text.match(/^d$/)) {
			obj.val({/literal}'{translate}Wear the prev-glasses{/translate}'{literal});
			return;
		}
		if (text.match(/^t$/)) {
			obj.val({/literal}'{translate}Prev-lens{/translate}'{literal});
			return;
		}
	}
	function checkCorrectGlass(obj) {
		var text = $.trim(obj.val());
		text = text.toLowerCase();
		if (text.match(/^p$/)) {
			obj.val('Plano');
			return;
		}
	}
</script>
{/literal}
<div id="divRefraction" class="form_container2" style="display: block;">
	<form id="frmRefractionEdit" action="../EyeRefraction/EditEyeRefraction" method="post">
		<input type="hidden" name="refractionId" id="refractionId" value="{$refraction->getId()}">
		<input type="hidden" name="recordId" id="recordId" value="{$recordId}">
		<span id="statusMessageRefraction" class='formAlertMsg'></span>
		
		<table border="0" cellpadding="0" cellspacing="0" style='margin-bottom: 10px;'>
		   <tr>
		      <td class="label">
		        {translate}Examination date{/translate}
		      </td>
		      <td class="field">
		      	{$createdDate}
		      </td>
		      <td class="label">
		      	{translate}Dr/Technician examines{/translate}
		      </td>
		      <td colspan="2" class="field">
		        {$doctorName}
		        <input name="doctorId" id="doctorId" type="hidden" value="{$doctorId}">
		      </td>
		   </tr>
		   <tr>
		      <td class="label">
		        {translate}Latest update{/translate}
		      </td>
		      <td class="field">
		      	{$updatedDate}
		      </td>
		      <td class="label">
		      	{translate}Dr/Technician updated{/translate}
		      </td>
		      <td colspan="2" class="field">
		        {$doctorUpdate}
		      </td>
		   </tr>
		</table>
		
		<table border="0" cellpadding="0" cellspacing="0">
			<thead>
				<tr>
					<td>&nbsp;</t>
					<td align="center" class="label">{translate}Right eye{/translate}</td>
					<td align="center" class="label">{translate}Left eye{/translate}</td>
					
				</tr>
			</thead>
			<tbody>
				<tr>
					<td align="left" class="label">
						<span>{translate}Errors of refraction{/translate}</span>
					</td>
					<td>
						<input name="rightRefractionType" id="rightRefractionType" type="text" value="{$refraction->getRightRefrationType()}" size="25"/>
					</td>
					<td>
						<input name="leftRefractionType" id="leftRefractionType" type="text" value="{$refraction->getLeftRefrationType()}" size="25"/>
					</td>			
				</tr>
				<tr style='display: none'>
					<td colspan="3" align="left" class="label">
						<span>{translate}Javal result{/translate}</span>
					</td>
				</tr>
				<tr style='display: none'>
					<td align="right" class="label">
						<i><span>K1</span></i>
					</td>
					<td>
						<input name="rightJavalK1" id="rightJavalK1" type="text" value="{$commonInfo->getRightJavalK1()}" size="25"/>
					</td>
					<td>
						<input name="leftJavalK1" id="leftJavalK1" type="text" value="{$commonInfo->getLeftJavalK1()}" size="25"/>
					</td>			
				</tr>
				<tr style='display: none'>
					<td align="right" class="label">
						<i><span>K2</span></i>
					</td>
					<td>
						<input name="rightJavalK2" id="rightJavalK2" type="text" value="{$commonInfo->getRightJavalK2()}" size="25"/>
					</td> 
					<td>
						<input name="leftJavalK2" id="leftJavalK2" type="text" value="{$commonInfo->getLeftJavalK2()}" size="25"/>
					</td>	
				</tr>
				<tr>
					<td colspan="3" align="left" class="label">
						<span>{translate}Vision acuity{/translate}</span>
					</td>
				</tr>
				<tr>
					<td align="right" class="label">
						<i><span>{translate}Without correction{/translate}</span></i>
					</td>
					<td>
						<input name="rightCVA" id="rightCVA" type="text" value="{$commonInfo->getRightCVA()}" size="25"/>										
					</td>
					<td>
						<input name="leftCVA" id="leftCVA" type="text" value="{$commonInfo->getLeftCVA()}" size="25"/>
					</td>
					
				</tr>
				<tr>
					<td align="right" class="label">
						<i><span>{translate}With correction{/translate}</span></i>
					</td>
					<td>
						<input name="rightUCVA" id="rightUCVA" type="text" value="{$commonInfo->getRightUCVA()}" size="25"/>
					</td>
					<td>
						<input name="leftUCVA" id="leftUCVA" type="text" value="{$commonInfo->getLeftUCVA()}" size="25"/>
					</td>
					
				</tr>
				<tr>
					<td align="left" class="label">
						<span>{translate}Biocular vision{/translate}</span>
					</td>
					<td colspan='2'>
						<input name="bothEyesight" id="bothEyesight" type="text" value="{$commonInfo->getBothEyesight()}" size="25"/>
					</td>
				</tr>
				<tr>
					<td align="left" class="label">
						<span>{translate}Eye glasses{/translate}</span>
					</td>
					<td>
						<input name="rightCorrectGlass" id="rightCorrectGlass" type="text" value="{$refraction->getRightCorrectGlass()}" size="25">
					</td>
					<td>
						<input name="leftCorrectGlass" id="leftCorrectGlass" type="text" value="{$refraction->getLeftCorrectGlass()}" size="25">
					</td>	
				</tr>
				<tr>
					<td align="left" class="label">
						<span>{translate}Near vision{/translate} + Add</span>
					</td>
					<td>
						<input name="rightVisualAcuity" id="rightVisualAcuity" type="text" value="{$refraction->getRightVisualAcuity()}" size="25">
					</td>
					<td>
						<input name="leftVisualAcuity" id="leftVisualAcuity" type="text" value="{$refraction->getLeftVisualAcuity()}" size="25">
					</td>			
				</tr>
				<tr>
					<td align="left" class="label">
						<span>{translate}Pupil distance (PD){/translate}</span>
					</td>
					<td colspan='2'>
						<input name="interocularDistance" id="interocularDistance" type="text" value="{$refraction->getInterocularDistance()}" size="25">
					</td>
				</tr>
				<tr>
					<td align="left" class="label">
						<span>Skiascopy</span>
					</td>
					<td>
						<input name="rightSkiascopy" id="rightSkiascopy" type="text" value="{$refraction->getRightSkiascopy()}" size="25">
					</td>
					<td>
						<input name="leftSkiascopy" id="leftSkiascopy" type="text" value="{$refraction->getLeftSkiascopy()}" size="25">
					</td>			
				</tr>
				<tr>
					<td align="left" class="label">
						<span>{translate}Currently corrected glasses{/translate}</span>
					</td>
					<td>
						<input name="rightCurrentDiopter" id="rightCurrentDiopter" type="text" value="{$refraction->getRightCurrentDiopter()}" size="25">
					</td>
					<td>
						<input name="leftCurrentDiopter" id="leftCurrentDiopter" type="text" value="{$refraction->getLeftCurrentDiopter()}" size="25">
					</td>		
				</tr>
				<tr>
					<td align="left" class="label">
						<span>{translate}PD of currently corrected glasses{/translate}</span>
					</td>
					<td colspan='2'>
						<input name="KCTK" id="KCTK" type="text" value="{$refraction->getCurrentKCTK()}" size="25">
					</td>
				</tr>
				<tr>
					<td align="left" class="label">
						<span>{translate}Suggestive glasses{/translate}</span>
					</td>
					<td>
						<textarea name="rightSuggestion" id="rightSuggestion" style='width: 173px; height: 40px'>{$refraction->getRightSuggestion()}</textarea>
					</td>
					<td>
						<textarea name="leftSuggestion" id="leftSuggestion" style='width: 173px; height: 40px'>{$refraction->getLeftSuggestion()}</textarea>
					</td>			
				</tr>
				<tr>
		      		<td valign="top" class="label">
		         		{translate}Note{/translate}
		      		</td>
		      		<td colspan="2">
		         		<textarea name="refNote" id="refNote" style='width: 359px; height: 40px'>{$refraction->getNote()}</textarea>
		      		</td>   
		   		</tr>
		   		<tr>
		   			<td>&nbsp;</td>
		   			<td colspan="2" class="label"><input type="checkbox" name="potentialLasik"
		   				{if $patient->get('potential_for') == 'lasik'}checked="checked"{/if}> &nbsp;&nbsp;{translate}Lasik potential{/translate}</td>
		   		</tr>
				<tr>
					<td colspan="2" align="left">
						<input id="btnSave" type="button" onclick="javascript:submitForm()" value="{translate}Save{/translate}">
				   		<div id="divEditMessageBarLoading" style="display:none;" align="center">
							<img src="{$base_uri}/images/ajax-loader.gif"/>
						</div>
				   		<!--<input type="button" onclick="printRef('vi')" value="{translate}In đơn kính{/translate}">
				   		<input type="button" onclick="printRef('en')" value="{translate}In tiếng Anh{/translate}">
						-->
						</td>
					<td align='left'>
		   				<div id='lblEditMessage' style='font-style: italic'></div>
		   			</td>
				</tr>
			</tbody>
		</table>
	</form>
</div>
<input name="wantPrint" id="wantPrint" type="hidden" value="" size="25">